Page({
    data: {
      buttonList: [
        { label: '按钮1', value: 'action1' },
        { label: '按钮2', value: 'action2' },
        { label: '按钮3', value: 'action3' },
        { label: '按钮4', value: 'action4' },
        { label: '按钮5', value: 'action5' },
        { label: '按钮6', value: 'action6' },
        { label: '按钮7', value: 'action7' },
        { label: '按钮8', value: 'action8' },
        { label: '按钮9', value: 'action9' },
        { label: '按钮10', value: 'action10' }
      ],
      Action_selected: ''
    },
    onActionSelected(e) {
      const value = e.detail.value;
      this.setData({
        Action_selected: value
      });
      console.log('选中的操作:', this.data.Action_selected);
    },

    btn_test(){
        // const numbers = [1, 2, 3, 4, 5];
        // // 使用 map 函数对数组中的每个元素进行平方操作
        // const squaredNumbers = numbers.map(function(num) {
        //     return num * num;
        // });
        //         console.log('原数组:', numbers);
        // console.log('平方后的数组:', squaredNumbers); 

        // const names = ['Alice', 'Bob', 'Charlie'];

        // // 使用箭头函数对数组中的每个元素添加前缀
        // const newNames = names.map(name1 => `Hello, ${name1}!`);

        // console.log('原数组:', names);
        // console.log('添加前缀后的数组:', newNames);

        const students = [
            { name: 'Alice', score: 85 },
            { name: 'Bob', score: 90 },
            { name: 'Charlie', score: 78 }
        ];
        
        // 使用 map 函数提取每个学生的分数
        const scores = students.map(student1 => student1.score);
        
        console.log('学生对象数组:', students);
        console.log('学生分数数组:', scores);


        const objects = [
            { name: 'Alice', age: 25 },
            { name: 'Bob', age: 30 },
            { name: 'Charlie', age: 35 }
        ];
        
        const mergedObject = objects.reduce((accumulator, currentObject) => {
            return { ...accumulator, ...currentObject };
        }, {});
        
        console.log(mergedObject); 

        function sum(a, b, c) {
            return a + b + c;
        }
        
        const numbers = [1, 2, 3, 4 ];
        const result = sum(...numbers);
        
        console.log(result); // 输出: 6


    },

    playVideo() {
        const videoContext = wx.createVideoContext('myVideo');
        videoContext.play();
    }
});